package com.wanmait.recruitment.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.recruitment.mapper.ProductsMapper;
import com.wanmait.recruitment.pojo.Products;
import com.wanmait.recruitment.service.ProductService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class ProductServiceImpl implements ProductService {
    @Resource
    private ProductsMapper productsMapper;
    @Override
    @CacheEvict(value = "productCache",allEntries = true)
    public void insert(Products products) {
        productsMapper.insert(products);
    }

    @Override
    @Cacheable("productCache")
    public List<Products> selectById(Integer id) {
        return productsMapper.selectById(id);
    }

    @Override
    @CacheEvict(value = "productCache",allEntries = true)
    public void updateEnable(Integer id) {
        productsMapper.updateEnable(id);
    }

    @Override
    @CacheEvict(value = "productCache",allEntries = true)
    public void save(Products products) {
        productsMapper.save(products);
    }

    @Override
    public void delete(Integer id) {

    }

    @Override
    public void delete(String ids) {

    }

    @Override
    @CacheEvict(value = "productCache",allEntries = true)
    public void update(Products products) {
        productsMapper.updateByPrimaryKeySelective(products);
    }

    @Override
    public Products findById(Integer id) {
        return null;
    }

    @Override
    public List<Products> findAll() {
        return null;
    }

    @Override
    public List<Products> findAll(Products object) {
        return null;
    }

    @Override
    public PageInfo<Products> findPage(int pageNum, int pageSize) {
        return null;
    }
}
